<script>
export default {
  data() {
    return {

      pojo: {},
      user:{},
    };
  },
  methods: {
    // findPage(){
    //   this.form=this.user;
    //   this.axios.post('http://localhost:9000/user/findPage',this.form).then(response => {
    //     this.tableData.push(response.data.data);
    //     this.pojo=response.data.data;
    //   })
    // },
    finduser(){
      var a=localStorage.getItem("user")
      this.user=JSON.parse(a)
      this.pojo = this.user;
      this.pojo.password=""
      console.log(this.user)

    },
    // change(){
    //   this.pojo=this.user;
    //   this.axios.post('http://localhost:9000/user/reset',this.pojo).then(res=>{
    //     if (res.data.code === 200) {
    //       this.findPage()
    //       this.$message({
    //         type: 'ok',
    //         message: "更新成功"
    //       })
    //     } else {
    //       this.$message({
    //         type: 'fail',
    //         message: "更新失败"
    //       })
    //     }
    //   })
    //
    // }

    change() {
      this.axios.post('http://localhost:9000/a/user/reset', this.pojo).then(res => {
        if (res.data.code === 200) {
          this.$message({
            type: 'ok',
            message: res.data.data
          });
        } else {
          this.$message({
            type: 'fail',
            message: res.data.data
          });
        }
      }).catch(error => {
        console.error("更新请求发生错误:", error);
        this.$message({
          type: 'error',
          message: "请求失败，请重试"
        });
      });
    }



  },
  created() {
    this.finduser();
    // this.findPage();
  }
};
</script>
<template>
  <div align="left" class="c">

    <router-view/>
    <el-container>
      <el-header><b style="font-size: 20px;">重置密码</b></el-header>
      <hr>
      <el-main>
        <el-row>
          <br>
          <div class="div1">
            <el-form :model="pojo">
              <el-form-item label="旧密码">
                <el-input v-model="pojo.password" placeholder="请输入旧密码" style="width: 200px"></el-input>
              </el-form-item>
              <el-form-item label="新密码">
                <el-input v-model="pojo.newpassword1" placeholder="请输入新密码" style="width: 200px"></el-input>
              </el-form-item>
              <el-form-item label="确认新密码">
                <el-input v-model="pojo.newpassword2" placeholder="请确认新密码" style="width: 200px"></el-input>
              </el-form-item>
            </el-form>
          </div>
          <br>
        </el-row>
      </el-main>
      <hr>
      <br>
      <el-button type="primary" style="width: 100px" @click="change">保 存</el-button>
    </el-container>
  </div>
</template>

<style>
.c {
  background-color: #F2F7FB;
  border: 1px solid #d3dce6;
  border-radius: 5px;
  padding: 10px;
  margin: 10px;
  width: 100%;
  height: 90%;
  overflow: auto;
}
.div1{
  width: 400px;
  height: 200px;
  margin: 0 auto;
}
</style>

